﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<ManWebRole.Models.Account>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	EditAccount
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>EditAccount</h2>

    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>
        
        <fieldset>
            <legend>Fields</legend>

            <div class="editor-label">
                <%: Html.LabelFor(model => model.ProjectId) %>
            </div>
            <div class="editor-field">
                <select style="width: 204px" name="projectSelect">
                <%    
          if (Model.ProjectId != null)
          {
             var projects = new ManWebRole.Models.ProjectModel().GetAllProjects();
             foreach (var item in projects)
             {
                Response.Write("<option ");
                if (item.Id == Model.ProjectId)
                {
                   Response.Write("Selected ");
                }
                Response.Write("value=" + item.Id + ">" + item.Name + "</option>");
             }
          }
          else
          {
             Response.Write("<option value='-1'>None</option>");
          }
                %>
                </select>
               <%-- <%: Html.TextBoxFor(model => model.ProjectId) %>
                <%: Html.ValidationMessageFor(model => model.ProjectId) %>--%>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.UserName) %>
            </div>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.UserName) %>
                <%: Html.ValidationMessageFor(model => model.UserName) %>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Password) %>
            </div>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.Password) %>
                <%: Html.ValidationMessageFor(model => model.Password) %>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Type) %>
            </div>
            <div class="editor-field">
                <select name="userTypeSelect" style="width: 204px">
                    <%
           string[] typeNames = { "Project Administrator", "Software Requirements Engineer",
                                  "Project Customer", "Builtin Administrator"};
           for (int i = 0; i < typeNames.Length; i++)
           {
               Response.Write("<option value='" + i + "' ");
               if (Model.Type == i)
               {
                   Response.Write("Selected ");
               }
                   Response.Write(">");
                       Response.Write(typeNames[i]+"</option>");
           }
                    %>   
                </select>
            </div>
            
            <p>
                <input type="submit" value="Save" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%: Html.ActionLink("Back to List", "AccountList") %>
    </div>

</asp:Content>

